/**
 * 文件名:WorksServiceImpl.java
 * 包名:com.wx.demo.wcd.service.impl
 * 创建时间:2017年2月22日下午4:49:54
 * <p>Copyright ®医界互联 TUS 平台版权所有。</p>
 *
 */

package com.wx.demo.wcd.service.impl;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wx.demo.wcd.domain.po.WorksPO;
import com.wx.demo.wcd.domain.qo.WorksQO;
import com.wx.demo.wcd.infrastructure.dao.WorksDao;
import com.wx.demo.wcd.service.WorksService;
import com.yjhl.framework.dao.query.Page;

/**
 * 类名:WorksServiceImpl <br/>
 * 创建时间: 2017年2月22日 下午4:49:54 <br/>
 * 
 * @works 王笑 Email:wangxiao@yijiehulian.com.
 * @version
 * @since JDK 1.8
 * @see
 */
@Service("worksService")
public class WorksServiceImpl implements WorksService {
	private Logger logger = Logger.getLogger(getClass());

	@Autowired
	private WorksDao worksDao;

	@Override
	public int insert(WorksPO works) throws Exception {

		logger.debug("insert works content ===>" + works.inputDescription());

		int rows = worksDao.insert(works);

		logger.debug("insert works columns ===> " + rows);

		return rows;
	}

	@Override
	public int insertBatch(List<WorksPO> la) throws Exception {

		logger.debug("insertBatch List<WorksPO> lp content ===>"
				+ la.toString());

		int rows = worksDao.insertBatch(la);

		logger.debug("insertBatch columns ===> " + rows);

		return rows;
	}

	@Override
	public int edit(WorksPO entityPo, WorksQO entityQo) throws Exception {

		logger.debug("edit entityPo content ===>" + entityPo.inputDescription());
		logger.debug("edit entityQo content ===>" + entityQo.inputDescription());

		int rows = worksDao.updateSelective(entityPo, entityQo);

		logger.debug("edit columns ===> " + rows);

		return rows;
	}

	@Override
	public int delete(String works_id) throws Exception {
		logger.debug("delete works_id content ===>" + works_id);

		int rows = worksDao.deleteByPk(works_id);

		logger.debug("delete columns ===>" + rows);

		return rows;
	}

	@Override
	public int deleteBatch(WorksQO works) throws Exception {

		logger.debug("deleteBatch WorksQO content ===>"
				+ works.inputDescription());

		int rows = worksDao.delete(works);

		logger.debug("deleteBatch columns ===>" + rows);

		return rows;
	}

	@Override
	public WorksPO selectById(String works_id) throws Exception {

		logger.debug("selectById works_id content ===>" + works_id);

		WorksPO entity = worksDao.getByPk(works_id);

		logger.debug("selectById columns ===>" + entity.inputDescription());

		return entity;
	}

	@Override
	public Page<WorksPO> selectCondition(WorksQO works) throws Exception {

		logger.debug("selectCondition WorksQO content ===>"
				+ works.inputDescription());

		Page<WorksPO> entity = worksDao.find(works);

		logger.debug("selectCondition columns ===>" + entity.toString());

		return entity;
	}

	@Override
	public Page<WorksPO> selectAll(WorksQO works) throws Exception {

		logger.debug("selectCondition WorksQO content ===>"
				+ works.inputDescription());

		Page<WorksPO> entity = worksDao.find(works);

		logger.debug("selectCondition columns ===>" + entity.toString());

		return entity;
	}

	@Override
	public int selectCount(WorksQO works) throws Exception {

		logger.debug("selectCount WorksQO content ===>"
				+ works.inputDescription());

		int rows = worksDao.count(works);

		logger.debug("selectCount columns ===>" + rows);

		return rows;
	}

}
